<?php
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename=pemenang_arisan.xls');
header('Cache-Control: max-age=0');

?>

  <h2 class="title">REKAP PEMENANG ARISAN BULAN <?php 
  	if ($bln==01){
  	$bulan ="JANUARI";
  	}else if ($bln==02){
  	$bulan ="FEBRUARI";
	}else if ($bln==03){
  	$bulan ="MARET";
	}else if ($bln==04){
  	$bulan ="APRIL";
	}else if ($bln==05){
  	$bulan ="MEI";
	}else if ($bln==06){
  	$bulan ="JUNI";
	}else if ($bln==07){
  	$bulan ="JULI";
	}else if ($bln==08){
  	$bulan ="AGUSTUS";
	}else if ($bln==09){
  	$bulan ="SEPTEMBER";
	}else if ($bln==10){
  	$bulan ="OKTOBER";
	}else if ($bln==11){
  	$bulan ="NOVEMBER";
	}else if ($bln==12){
  	$bulan ="DESEMBER";}
	
  echo $bulan?> <?php echo $tahun?></h2><br>

	   <table width="100%" border="1" cellpadding="1" cellspacing="1" id="data" align="center">
        <thead>
       <tr  align="center">
           <th rowspan="2">No</th>
           <th rowspan="2">Nama Dealer</th>
           <th rowspan="2">Upline</th>
            <th rowspan="2">Unit</th>
            <th rowspan="2">Cicilan ke-</th>
            <th colspan="3">Harga</th>
            <th rowspan="2">Komisi</th>
            <th rowspan="2">Netto</th>
            <th rowspan="2">Omset</th>
            <th rowspan="2">PV</th>
        </tr>
        <tr  align="center">
        <td>Retail</td>
        <td>DP</td>
        <td>Angsuran</td>
        </tr>
    </thead>
    <tbody>

    <!-- ============isi ============ -->

		<?php
        if(!empty($default)){
          	$i=1;
			foreach($default as $m) :
           	if ($m->intid_wilayah==1){
                $harga = $m->intharga_jawa;
				$cicil = $m->intcicilan_jawa;
            }else {
                $harga = $m->inthrga_luarjawa;
				$cicil = $m->intcicilan_luarjawa;
            }
		?>
     	<tr class='data' align='center'>
			<td ><?php echo $i++; ?></td>
            <td align='left'>&nbsp;<?php echo $m->strnama_dealer; ?></td>
            <td align='left'>&nbsp;<?php echo $m->strnama_upline; ?></td>
            <td align='left'>&nbsp;<?php echo $m->strnama_unit; ?></td>
            <td align='left'>&nbsp;<?php echo $m->urutan_pemenang; ?></td>
            <td align='left'>&nbsp;<?php echo "Rp. ".number_format($harga,2 , ',' , '.') ?></td>
            <td align='left'>&nbsp;<?php echo "Rp. ".number_format($m->intuang_muka,2 , ',' , '.') ?></td>
            <td align='left'>&nbsp;<?php echo "Rp. ".number_format($cicil,2 , ',' , '.') ?></td>
            <td align='left'>&nbsp;<?php 
			if ($m->intkomisi10<>0){
				$komisi = $m->intkomisi10*$sisa;
			} else if ($m->intkomisi20<>0){
				$komisi = $m->intkomisi20*$sisa;
			} else if (($m->intkomisi10<>0) && ($m->intkomisi20<>0)){
				$komisi = ($m->intkomisi10 + $m->intkomisi20)*$sisa;
			} else {
				$komisi = 0;
			}
			echo "Rp. ".number_format($komisi,2 , ',' , '.'); ?></td>
            <td align='left'>&nbsp;<?php $netto = $m->intuang_muka - $komisi; echo "Rp. ".number_format(0,2 , ',' , '.'); ?></td>
          	<td align='left'>&nbsp;<?php echo "Rp. ".number_format(($m->inttotal_omset)*$sisa,2 , ',' , '.'); ?></td>
            <td align='left'>&nbsp;<?php echo $m->intpv*$sisa; ?></td>	
        </tr>
		<?php
        endforeach;
        ?>
        
        <?php
        }else{
        ?>
    <tr>
        <td colspan="10" align="center">
            No Data Display
        </td>
    </tr>
    <?php } ?>

    </tbody>
</table>
               
<div id="bayar" style="width:400px; height: 100px;"></div>
<div id="f_error" style="width:400px; height: 100px;"></div>
<div id="klik_b" style="width:400px; height: 100px;"></div>
     